package com.macro.client.controller;

import com.github.pagehelper.PageInfo;
import com.macro.client.dto.ProductDto;
import com.macro.client.service.HomeService;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.HomeContentResult;
import com.macro.mall.model.PmsBrand;
import com.macro.mall.model.PmsProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName HomeController
 * @Description 描述
 * @Author bai
 * @Date 2024/10/22 10:40
 */


@RestController
@RequestMapping("/brand")
public class HomeController {

    @Autowired
    private HomeService homeService;


    /**
     * 品牌列表
     */
    @GetMapping("/content")
    public CommonResult<HomeContentResult> getHomeContent(){
        HomeContentResult list = homeService.getHomeContent();
        return CommonResult.success(list);
    }

    /**
     *品牌回显
     */
    @GetMapping("/detail/{id}")
    public CommonResult<PmsBrand> detail(@PathVariable Integer id){
        PmsBrand pmsBrand = homeService.detail(id);
        return CommonResult.success(pmsBrand);
    }

    /**
     * 分页查询
     */
    @PostMapping("/productList")
    public CommonResult<PageInfo<PmsProduct>> productList(@RequestBody ProductDto productOfBrandRequest){
        PageInfo<PmsProduct> pmsProductPageInfo = homeService.fetchBrandProductList(productOfBrandRequest);
        return CommonResult.success(pmsProductPageInfo);
    }

}
